<!-- 订阅组件 -->
<script setup lang="ts" name="followigIndex">
import { onMounted } from 'vue'
import useFollowigIndex from '@/components/index/followig/hooks/followigIndex'
const { userColumns, searchKey, tags, activeTab, tagsData, changeComponents } = useFollowigIndex()
onMounted(() => {
  changeComponents(0)
})
</script>
<template>
  <div id="followig">
    <ul ref="tags" id="selector">
      <li class="tab">订阅</li>
      <li
        v-for="item in tagsData"
        :key="item.id"
        class="tab"
        @click="changeComponents(item.id)"
        :class="{ active: activeTab === item.id }"
      >
        {{ item.title }}
      </li>
      <li class="search">
        <input type="text" v-model="searchKey" />
      </li>
    </ul>
    <div id="content">
      <component :is="userColumns" :searchKey="searchKey"></component>
    </div>
  </div>
</template>

<style scoped lang="less">
.active {
  background-color: var(--color2);
  color: #fff;
}
.tab:nth-child(1) {
  background-color: var(--color2);
  color: #fff;
  border-radius: var(--radius) 0 0 0;
}
.tab:nth-child(2) {
  border-radius: 0;
}
.tab:nth-child(3) {
  border-radius: 0 var(--radius) 0 0;
}
.search-button {
  border-radius: 0 var(--radius) var(--radius) 0;
}

#followig {
  padding: 6px 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  > #selector {
    position: relative;
    padding: 0 10px;
    display: flex;
    height: 6%;
    box-sizing: border-box;
    border-radius: var(--radius) var(--radius) 0 0;
    li {
      list-style: none;
    }

    > .tab {
      cursor: pointer;
      list-style: none;
      width: 40px;
      height: 38px;
      line-height: 38px;
      padding: 0 10px;
      text-align: center;
      color: var(--color3);
    }
    .search {
      position: absolute;
      top: 50%;
      right: 20px;
      translate: 0 -50%;
      input {
        padding: 0 4px;
        height: 30px;
        box-sizing: border-box;
      }
      input:focus {
        outline: none;
      }
      span {
        display: inline-block;
        vertical-align: middle;
        width: 40px;
        height: 30px;
        line-height: 30px;
        text-align: center;
        padding: 0 10px;
      }
    }
  }
  > #content {
    position: relative;
    padding: 10px;
  }
}
</style>
